//Magnus Baunsgaard Kristensen s140168
//Jonathan Yannick Thomassen s125070

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JPanel;

public class MøntIndkast extends JPanel {

  JButton button50øre = new JButton();
  JButton button1kr = new JButton();
  JButton button2kr = new JButton();
  JButton button5kr = new JButton();
  JButton button10kr = new JButton();
  JButton button20kr = new JButton();

  Konsol ejer;

  public MøntIndkast(Konsol k) {
    try {
      init();
    } catch (Exception e) {
    }
    ejer = k;
  }

  private void init() throws Exception {
    button50øre.setText("50 øre");
    button1kr.setText("1 kr.");
    button2kr.setText("2 kr.");
    button5kr.setText("5 kr.");
    button10kr.setText("10 kr.");
    button20kr.setText("20 kr.");

    button50øre.setBounds(10, 10, 150, 50);
    button1kr.setBounds(10, 70, 150, 50);
    button2kr.setBounds(10, 130, 150, 50);
    button5kr.setBounds(10, 190, 150, 50);
    button10kr.setBounds(10, 250, 150, 50);
    button20kr.setBounds(10, 310, 150, 50);

    this.setLayout(null);
    this.add(button50øre);
    this.add(button1kr);
    this.add(button2kr);
    this.add(button5kr);
    this.add(button10kr);
    this.add(button20kr);

    button50øre.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        button50øre_actionPerformed(e);
      }
    });

    button1kr.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        button1kr_actionPerformed(e);
      }
    });

    button2kr.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        button2kr_actionPerformed(e);
      }
    });

    button5kr.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        button5kr_actionPerformed(e);
      }
    });

    button10kr.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        button10kr_actionPerformed(e);
      }
    });

    button20kr.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        button20kr_actionPerformed(e);
      }
    });
  }

  void button50øre_actionPerformed(ActionEvent e) {
    ejer.møntInput("50øre");
  }

  void button1kr_actionPerformed(ActionEvent e) {
    ejer.møntInput("1kr");
  }

  void button2kr_actionPerformed(ActionEvent e) {
    ejer.møntInput("2kr");
  }

  void button5kr_actionPerformed(ActionEvent e) {
    ejer.møntInput("5kr");
  }

  void button10kr_actionPerformed(ActionEvent e) {
    ejer.møntInput("10kr");
  }

  void button20kr_actionPerformed(ActionEvent e) {
    ejer.møntInput("20kr");
  }
}
